#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->light_switch->setEnabled(false);//按键失能
    ui->light_switch->setEnabled(true);//按键失能
//    QIcon icon("C:/Users/123/Pictures/Screenshots/屏幕截图 2024-05-19 232101.png");
//    ui->toolButton->setIcon(icon);
    //ui->toolButton->setIcon(QIcon("C:/Users/123/Pictures/Screenshots/屏幕截图 2024-05-19 232101.png"));
   // ui->toolButton->setIcon(QIcon(":/QQ.ico"));
    ui->toolButton->setIcon(QIcon(":/QQ.ico"));
    //动态添加
    //QListWidget
    //QListIterator
    //ui->listWidget->addItem("123455678898");
    ui->listWidget->addItem(new QListWidgetItem(QIcon(":/QQ.ico"),"qqqqqqqq"));
    //QFrame组件
    ui->frame->setAutoFillBackground(true);//背景检测使能
    ui->frame->setPalette(QPalette(Qt::red));//设置调色板
    //QCombo Box
    ui->comboBox->addItem("成都");
    ui->comboBox->addItem("haha");
    ui->comboBox->removeItem(1);//删除下标为1的item
    //QLineEdit 行编辑器
     ui->lineEdit->setText("0");
   // ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit->setMaxLength(6);
    int a =ui->lineEdit->text().toInt();
    qDebug()<< a;
    //QSpinBox
    ui->spinBox->setValue(1);
    ui->spinBox->setMinimum(0);
    ui->spinBox->setMaximum(5);
    ui->spinBox->setSingleStep(1);
    //Qlable
    ui->label_3 ->setText("aad");
    QPixmap pixmap;
    pixmap.load(":/屏幕截图 2024-05-20 000939.png");//将图像像素点装载导pixmap
    ui->label_3->setPixmap(pixmap);
    ui->label_3->setScaledContents(true);//内容自适应
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_light_switch_clicked()
{
    static bool flag = false;
    if(flag){
        ui->light_switch->setText("ON");
        flag = false;
    }else{
        ui->light_switch->setText("OFF");
        flag = true;
    }
}

void Widget::on_light_switch_pressed()
{
    qDebug()<< "pressed";
}


void Widget::on_light_switch_released()
{
     qDebug()<< "released";
}


void Widget::on_down_clicked()
{
    qDebug()<<"??";
    QListWidgetItem *item = ui->listWidget->takeItem(ui->listWidget->currentRow());
     ui->listWidget_2->addItem(item);
    ui->listWidget->sortItems();
    ui->listWidget_2->sortItems();




}

void Widget::on_radioButton_3_clicked()
{
    ui->groupBox->setTitle("A");
    qDebug()<< ui->groupBox->title();
}

void Widget::on_radioButton_6_clicked()
{
     ui->groupBox->setTitle("B");
}

void Widget::on_radioButton_5_clicked()
{
     ui->groupBox->setTitle("C");
}

void Widget::on_radioButton_4_clicked()
{
    ui->groupBox->setTitle("D");
}

void Widget::on_comboBox_currentIndexChanged(int index)
{
    qDebug()<<index;
    //ui->comboBox->removeItem(index);
   // ui->comboBox->removeItem(1);//删除下标为1的item
}

void Widget::on_fontComboBox_currentFontChanged(const QFont &f)
{
    ui->label->setFont(f);
}

void Widget::on_spinBox_valueChanged(int arg1)
{
    qDebug() <<arg1;
}

void Widget::on_verticalSlider_2_actionTriggered(int action)
{
    qDebug()<<action;
    ui->progressBar->setValue(action);
}
